package juc;

import java.util.concurrent.TimeUnit;

class Phone{

    public static synchronized void sendEmail(){
        try {
            TimeUnit.SECONDS.sleep(4);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("----------sendEmail");
    }

    public synchronized void sendSMS(){
        System.out.println("----------sendSMS");
    }
    public void hello(){
        System.out.println("----------hello");
    }
}

/**
 * 多线程8锁
 *
 * 1.标准访问 先打印邮件还是短信?
 * 2.邮件暂停4秒?
 * 3.新增hello?
 * 4.两个phone?
 * 5.两个静态同步方法,同一个phone?
 * 6.两个静态同步方法,两个phone?
 * 7.一个静态同步方法,一个普通同步方法,一个phone?
 * 7.一个静态同步方法,一个普通同步方法,两个phone?
 */
public class Lock8 {
    public static void main(String args[]) throws InterruptedException {
        Phone phone = new Phone();
        Phone phone2 = new Phone();

        new Thread(() -> {
            phone.sendEmail();
        },"A").start();

        Thread.sleep(100);

        new Thread(() -> {
            phone2.sendSMS();
//            phone.hello();
//            phone.sendSMS();
        },"B").start();
    }
}
